﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ZhishidengController : MonoBehaviour {

    private Color c_touruType = Color.yellow;//投入状态下显示黃色灯
    private Color c_dongzuoType = Color.red; //动作后显示红色灯
    public Transform tf_zhishideng;

    // Use this for initialization
    void Start () {
        EventManager<Unit>.AddEvent(MyEventType.ZhishidengTypeEvent,ChangeColor);	
	}

    void ChangeColor(Unit unit) {
        if (unit.s_name == "tuichu")
        {
            tf_zhishideng.GetChild(unit.i_index).gameObject.SetActive(false);
        }
        else if (unit.s_name == "touru")
        {
            tf_zhishideng.GetChild(unit.i_index).gameObject.SetActive(true);
            tf_zhishideng.GetChild(unit.i_index).GetComponent<MeshRenderer>().material.color = c_touruType;
        }
        else if (unit.s_name == "dongzuo") {
            tf_zhishideng.GetChild(unit.i_index).gameObject.SetActive(true);
            tf_zhishideng.GetChild(unit.i_index).GetComponent<MeshRenderer>().material.color = c_dongzuoType;
        }
    }
}
